﻿@{
    Layout = "_LayoutH";
}

@section styles{
    <style>
        .titleP {
            color: darkslateblue;
            font-weight: 600;
            font-size: 20px;
            text-align: center;
        }
    </style>
}

<div id="app" v-cloak>
    <p class="titleP">@ViewBag.stockTypeName 详情</p>
    <table id="bootstraptable" class="table table-bordered text-nowrap table-hover"></table>
    <div class="row">
        <div class="col-sm-3 col-sm-push-4">
            <button class="btn btn-info" v-on:click="closeSelf">关闭</button>
        </div>
    </div>
</div>

@section scripts{
    <script>
        var app = new Vue({
            el: "#app",
            data: {
                stockType: '@ViewBag.stockType',
                datemin: '@ViewBag.dateMin',
                datemax: '@ViewBag.dateMax',
                materialId:'@ViewBag.materialId'
            },
            mounted: function () {
                var _self = this;
                setTimeout(function() {
                    _self.loadL();
                }, 500);
            },
            methods: {
                loadL: function () {
                    _self = this;
                    var obj = [
                    {
                        field: 'StockInId',
                        title: 'Id',
                        visible: false
                    }, {
                        field: 'MaterialName',
                        title: '物料名称',
                        align: 'center',
                        sortable: true
                        }, {
                            field: 'Unit',
                            title: '单位',
                            align: 'center',
                            sortable: true
                        }, {
                        field: 'CcNo',
                        title: '车船号',
                        align: 'center',
                        sortable: true
                    }, {
                        field: 'Weight',
                        title: '重量',
                        align: 'center',
                        sortable: true
                        }, {
                            field: 'Price',
                            title: '单价',
                            align: 'center',
                            sortable: true
                        }, {
                            field: 'Total',
                            title: '计价',
                            align: 'center',
                            sortable: true
                        }, {
                            field: 'Go',
                            title: '去向',
                            align: 'center',
                            sortable: true
                        }, {
                        field: 'Remark',
                        align: 'center',
                        title: '备注'
                    }, {
                        field: 'CreateDate',
                        align: 'center',
                        title: '创建时间',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return _self.jsonDateFormat(value);
                        }
                    }];

                    yui.table("bootstraptable", obj, tblConfigExt);
                },
                closeSelf: function () {
                    console.log("close");
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            }
        });

        var tblConfigExt = {
            url: "/StockIn/List",
            method: "POST",
            queryParams: function () {  // 查询时，需要传递的参数
                var params = this;
                var temp = {
                    limit: params.pageSize,     //页面大小
                    offset: params.pageSize * (params.pageNumber - 1),   //页码
                    sort: params.sortName,      //排序列名
                    order: params.sortOrder, //排序命令（desc，asc）
                    search: app.$data.search,
                    datemin: app.$data.datemin,
                    datemax: app.$data.datemax,
                    MaterialId: app.$data.materialId,
                    StockType: app.$data.stockType
                };
                return temp;
            },
            singleSelect: false,  //设置 true 将禁止多选。
            sortOrder: "desc", // 排序方式
            sortName: "CreateDate", // 排序字段
            uniqueId: "StockInId", //每一行的唯一标识，一般为主键列
            pageSize:50
        };
    </script>
}